<script>
	function delete_confirm(url){
		$("button[my-type=delete_confirm]").attr('onclick', 'window.location="'+url+'"');
		return true;
	}
        
        function get_Checked_Checkbox_By_Name(Input_Name) {
            var arr = [];
            $("input[name='" + Input_Name + "']:checked:enabled").each(function () {
                arr.push($(this).val());
            });
            
            $.ajax({
                type        : "POST",
                cache       : false,
                url         : "/auth/bookingStatus/checkCustomer/",
                data        : {id:arr},
                success: function(data) {
                    if(data == 1){
                       $("input[name='" + Input_Name + "']").removeAttr("checked");
                        alert("Bạn không được phép khởi tạo nhiều khách hàng trong 1 chứng từ");return false;
                    } else {
                        $('#voucherAdd').val(arr);
                    }
                }
            });
        }
        $("#voucherClick").on('click',function(e) {
            if($("#voucherAdd").val() == ""){
                alert("Vui lòng chọn 1 khách hàng cần tạo chứng từ");return false;
            }
            
            $.ajax({
                    type        : "POST",
                    cache       : false,
                    url         : "/auth/bookingStatus/voucher",
                    data        : {id:JSON.stringify($("#voucherAdd").val())},
                    success: function(responseData) {
                            
                            var myRegExp    = 'error';
                            var matchPos1   = responseData.search(myRegExp);

                            if(matchPos1 != -1){
                                //match
                                var json    = JSON.parse(responseData);
                                var _msg    = '';
                                for(var i = 0; i < json.length; i++) {
                                    var obj = json[i];
                                    if(obj.error == 1){
                                        var _msg = obj.msg + _msg;
                                    }
                                }
                                alert(_msg);return false;
                            } else {
                                //ko match
                                 $.fancybox(responseData, {
                                        margin		: 0,
                                        padding		: 0,
                                        maxWidth	: '480px',
                                        maxHeight	: '400px',
                                        fitToView	: false,
                                        width		: '100%',
                                        height		: '100%',
                                        autoSize	: false,
                                        closeClick	: false,
                                        openEffect	: 'none',
                                        closeEffect	: 'none',
                                        titleShow	: true,
                                        closeBtn	: false,
                                }); // fancybox
                            }

                    }
                });
                e.preventDefault();	//STOP default action
        });
</script>

<?php
if(isset($controller)){
 
    if(in_array($controller,array('statiticsHr','listcustomers','booking','bookhistory','bookingStatus','bookingDebts','voucherHistory'))){
        $this->load->view('templates/backend/datepicker');
    }

    if(in_array($controller,array('listexport','bookhistory','paymentAtHome','bookingStatus','customerAssess','flyTomorrow','bookYesterday','voucher','bookingDebts','paymentAir','voucherHistory','voucherArise','refundTicket','voucherLunisolar'))){
    ?>
        <link rel="stylesheet" href="<?php echo STATIC_URL;?>/backend/css/jquery.fancybox.css">
        <script type="text/javascript" src="<?php echo STATIC_URL;?>/backend/js/jquery.fancybox.js"></script>
        <script type="text/javascript" src="<?php echo STATIC_URL;?>/backend/js/_popup.js"></script>
    <?php
    }
    
    
}